#include <iostream>
#include <string>
#include <vector>

size_t split(const std::string &str, const std::string &sep, std::vector<std::string> &ret)
{
    // news....music.*.pop
    int pos, idx = 0;
    while (idx < str.size())
    {
        pos = str.find(sep, idx);
        if (pos == std::string::npos)
        {
            ret.push_back(str.substr(idx));
            return ret.size();
        }

        if (pos == idx)
        {
            idx += sep.size();
            continue;
        }

        ret.push_back(str.substr(idx, pos - idx));
        idx = pos + sep.size();
    }
    return ret.size();
}

int main()
{
    std::string str = "...news....music.#.pop...";
    std::vector<std::string> arry;
    int n = split(str, ".", arry);
    for (auto &s : arry)
    {
        std::cout << s << std::endl;
    }
    return 0;
}